home *** CD-ROM | disk | FTP | other *** search
- /*
- dshell v3
-
- メニューや情報表示など
- */
-
-
- #include "dsh.h"
-
- typedef struct {
- short dx; /* 表示開始座標offset */
- short dy; /* 表示開始座標offset */
- short wd; /* 表示文字列幅(半角) */
- char *mes; /* 表示文字列 */
- } SSLSTRCT;
-
- static int ssl_sub(int , int , SSLSTRCT *);
- static int setscrlin(void);
-
-
- /*
- menu_sx:[MENU]メニューのX始め桁
- */
- void
- menu(int menu_sx)
- {
- static const char *contents[] =
- {
- "テキスト印刷",
- "簡易操作説明",
- "音楽 演奏開始",
- "音楽 一時停止",
- "音楽 演奏再開",
- "改頁行数",
- "Cursor-Speed Switch", /* ver 2.3d */
- "Joystick-Mouse Switch", /* ver 2.3a */
- "Keyboard-Mouse Switch", /* ver 2.3a */
- "Realtime-Scroll-Window Size" /* ver 3.10b */
- };
- #define CM (sizeof(contents) / sizeof(contents[0])) /* メニュー項目数 */
-
- int dm, bl, br;
- int i;
- int x, y;
- int s, ss = -1;
- char buf[96];
- const int cwidth = CWIDTH;
-
- void JoyMouseSwitch(void);
- void KeyMouseSwitch(void);
- void CSpdUpSwitch(void);
-
- msarea((cwidth - 40) * 8, 472 - CM * 16, (cwidth - 2) * 8 - 1, 511);
- B_COLOR(5);
- win_frame(cwidth - 41, 27 - CM, cwidth - 3, 30, 29 - CM, menu_sx - 1);
-
- B_COLOR(7);
- B_LOCATE(cwidth - 39, 28 - CM);
- B_PRINT("[ MENU ] Select Line");
- B_COLOR(3);
- for (i = 0; i < CM; i++) {
- B_LOCATE(cwidth - 39, 30 - (CM - i));
- sprintf(buf, "%2d. %s", CM - i, contents[i]);
- B_PRINT(buf);
- }
-
- /*
- ★KEY/JOYマウス現在の使用状態(v2.3a,v2.3d)
- 下の6行は、メニューの追加・削除の際、
- Y表示座標を補正のこと。
- */
- B_LOCATE(cwidth - 26, 30 - (CM - 5));
- sprintf(buf, "%2d", scrlin);
- B_PRINT(buf);
- B_LOCATE(cwidth - 15, 30 - (CM - 6));
- sprintf(buf, "%s", (CSpdUp) ? "HIGH" : "NORMAL");
- B_PRINT(buf);
- B_LOCATE(cwidth - 13, 30 - (CM - 7));
- sprintf(buf, "%s", (Jflg) ? "ON" : "OFF");
- B_PRINT(buf);
- B_LOCATE(cwidth - 13, 30 - (CM - 8));
- sprintf(buf, "%s", (Kflg) ? "ON" : "OFF");
- B_PRINT(buf);
- B_LOCATE(cwidth - 7, 30 - (CM - 9));
- sprintf(buf, "%s", (Rwin_len == RW_FULL) ? "FULL" : "HALF");
- B_PRINT(buf);
-
- /*
- ! いったん離されるのを待つ
- */
- wait_mb_off();
-
-
- do {
- p_time(0);
- dmspos(&x, &y);
- if ((30 - CM) * 16 < y && y < 480) {
- s = y / 16 - 30 + CM;
- } else {
- s = -1;
- }
- if (s != ss) {
- if (s != -1) {
- B_COLOR(9);
- B_LOCATE(cwidth - 35, 30 - (CM - s));
- B_PRINT(contents[s]);
- }
- B_COLOR(3);
- if (ss != -1) {
- B_LOCATE(cwidth - 35, 30 - (CM - ss));
- B_PRINT(contents[ss]);
- }
- }
- ss = s;
- dmsstat(&dm, &dm, &bl, &br);
- } while (!(bl || br));
- if (br == -1) {
- s = -1; /* キャンセル */
- }
-
-
- if (s < CM) {
- switch (s) {
- case 0:
- d_print();
- break; /* 89.07.13 */
- case 1:
- onlinemanual();
- break; /* ver2.30 */
- case 2:
- dm_play('PLAY');
- break; /* 再変更:v3.01 */
- case 3:
- dm_play('STOP');
- break; /* 再変更:v3.01 */
- case 4:
- dm_play('CONT');
- break; /* 再変更:v3.01 */
- case 5:
- setscrlin();
- break;
- case 6:
- CSpdUpSwitch();
- break; /* 追加:v2.3d */
- case 7:
- JoyMouseSwitch();
- break; /* 追加:v2.3a */
- case 8:
- KeyMouseSwitch();
- break; /* 追加:v2.3a */
- case 9:
- Rwin_len_switch();
- break;
- }
- }
-
- p_lin(lp + 29, 29);
- for (i = 28; i >= 26 - CM; i--) {
- p_lin(lp + i, i);
- }
- msarea(0, 0, GWIDTH - 1, 511);
-
- wait_mb_off();
- }
-
-
-
-
- /*
- 音楽演奏関係のシステムコールを行なう
- 対応するパラメータは、
- PLAY
- STOP
- CONT
- のみ(あくまでメニュー用)
- */
- int
- dm_play(int param)
- {
- int opmcall_d1(int);
-
- switch (param) {
- case 'PLAY':
- return (opmcall_d1(8)); /* 8=play */
- case 'STOP':
- return (opmcall_d1(10)); /* 10=stop */
- case 'CONT':
- return (opmcall_d1(11)); /* 11=cont */
- default:
- return (-1);
- }
- }
-
-
- int
- Rwin_len_switch()
- {
- Rwin_len = (Rwin_len == RW_FULL) ? RW_HALF : RW_FULL;
- return (Rwin_len);
- }
-
-
- /*
- 頁スクロールの行数設定を変える
-
- (画面復元のことを考えないサブメニュー)
- */
- static int
- ssl_sub(int x, int y, SSLSTRCT *btn)
- {
- int i;
-
- for (i = 0; ; i++) {
- if (btn[i].wd == 0) {
- return -1;
- }
- if (y == btn[i].dy && x >= btn[i].dx && x < btn[i].dx + btn[i].wd) {
- return i;
- }
- }
- return -1;
- }
-
-
- static int
- setscrlin(void)
- {
- int i;
- int ox, oy; /* メニュー枠表示開始座標 */
- int wx, wy; /* メニュー枠表示幅 */
- int mx, my, ml, mr;
- int tmpscrlin;
- char buf[96];
-
- static const SSLSTRCT sslbtn[] = {
- {1, 2, 6, "初期化"}, /* 0 = 初期化 */
- {11, 2, 2, "<"}, /* 1 = decl */
- {19, 2, 2, ">"}, /* 2 = incl */
- {4, 3, 4, "決定"}, /* 3 = OK */
- {14, 3, 4, "取消"}, /* 4 = cancel */
- {0, 0, 0, ""}
- };
-
- ox = CWIDTH - 24;
- oy = 24;
- wx = 22;
- wy = 4;
- tmpscrlin = scrlin;
-
- msarea(ox * 8, (oy + 2) * 16, (ox + wx) * 8 - 1, (oy + wy) * 16 - 1);
-
- B_COLOR(5);
- win_frame(ox - 2, oy - 1, ox + wx, oy + wy, oy + 1, 0);
- B_COLOR(3);
-
- B_LOCATE(ox, oy);
- sprintf(buf, "改ページ行数(1~%d)", MAXSCRLIN);
- B_PRINT(buf);
-
- for (i = 0; sslbtn[i].wd; i++) {
- B_LOCATE(ox + sslbtn[i].dx - 1, oy + sslbtn[i].dy);
- sprintf(buf, "[%s]", sslbtn[i].mes);
- B_PRINT(buf);
- }
-
- while (1) {
- B_LOCATE(ox + sslbtn[1].dx + 3, oy + 2);
- sprintf(buf, " %2d ", tmpscrlin);
- B_PRINT(buf);
- wait_mb_off();
- do {
- dmsstat(&mx, &my, &ml, &mr);
- dmspos(&mx, &my);
- p_time(0);
- } while (!(ml || mr));
- if (mr) {
- tmpscrlin = scrlin;
- break;
- }
- mx /= 8;
- my /= 16;
- switch (ssl_sub(mx - ox, my - oy, (SSLSTRCT *)&sslbtn)) {
- case 0: /* [初期化] */
- tmpscrlin = DEFSCRLIN;
- break;
- case 1: /* [<] */
- if (--tmpscrlin < 1) {
- tmpscrlin = 1;
- }
- break;
- case 2: /* [>] */
- if (++tmpscrlin > MAXSCRLIN) {
- tmpscrlin = MAXSCRLIN;
- }
- break;
- case 3: /* [決定] */
- goto BREAKLOOP;
- case 4: /* [取消] */
- tmpscrlin = scrlin;
- goto BREAKLOOP;
- }
- }
-
- BREAKLOOP:
- scrlin = tmpscrlin;
-
- return 0;
- }
-